<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<meta charset='utf-8' />
	<title>台账管理</title>
	<style>
		.cursers{cursor:pointer}
	</style>
</head>
<body style='background:#ddd;padding:0px;margin:0px;padding-left:10px'>
	<h1 style='text-align:center'>工号激活</h1>

	<div style='width:240px;border:0px solid;margin:0 auto'>
		<div style='margin:15px 0'>工　　号：<input type="text" id='account' style='width:150px' /></div>
		<div style='margin:15px 0'>姓　　名：<input type="text"  id='name' style='width:150px' /></div>
		<div style='margin:15px 0'>密　　码：<input type="password"  id='pwd' style='width:150px' /></div>
		<div style='margin:15px 0'>确认密码：<input type="password"  id='pwd2' style='width:150px' /></div>
		<div style='position:relative'>
			验证码　：<input type="text" style='width:50px' id='vcode' />
			<span style='position:absolute;left:140px;border:0px solid;width:90px;height:30px'><img src="../interface/before_interface.php?type=code" style='width:100%;height:100%' alt="点击" onclick="this.src=this.src+'&t='+Math.random()" id='vcodeImg'/></span>
		</div>

		<div style='margin:25px 0;text-align:center'>
			<button id='register'>激活</button>
			<button onclick='history.go(-1)'>返回</button>
		</div>
	</div>
</body>
</html>
<script src='../public/jquery1.1.js'></script>
<script src='../public/fun.js'></script>
<script>
$(function(){
	$('#register').click(function(){
		var account = m_trim($('#account').val());
		
		var name = m_trim($('#name').val());
		var pwd = m_trim($('#pwd').val());
		var pwd2 = m_trim($('#pwd2').val());
		var vcode = m_trim($('#vcode').val());
		if(!account || !name || !pwd || !pwd2 || !vcode){
			A('缺少必填项！');return;
		}

		if(!/^[1-9][0-9]*$/.test(account)){
			A('工号必须是非零开头的纯数字！');return;
		}

		if(pwd != pwd2){
			A('两次密码不一致！');return;
		}

		var data = {
			type:'register',
			account:account,
			name:name,
			pwd:pwd,
			vcode:vcode
		}
		Ajax(data,function(res){
			var tmp = _checkJsonFormat(res); //检测JSON格式
			if(res == '10003'){
				$('#vcodeImg').trigger('click');
			}
			sessionStorage.token1 = tmp.token1;
			switch(tmp.stat){
				case 'err1':A('缺少参数！');break;
				case 'err2':A('工号已存在！');break;
				case 'err3':A('工号激活异常！');break;
				case 'ok':A('工号激活成功！');location.replace('login.html');break;
			}
		});
	});

});	
</script>

